#!/bin/bash
cd '/home/ubuntu/django_projects/reload'
now_month=`date +"%Y-%m"`
today=`date +"%Y-%m-%d" `
echo "rm old log" >> $today.log
ls | grep .log | grep -v $now_month | xargs rm -f
echo "git pull..." >> $today.log
git pull >> $today.log 2>&1
echo "pip install..." >> $today.log
echo "minusli@plushu"| sudo pip install -r ../requirements >> $today.log 2>&1
bool=`ps -ef | grep -v =auto| grep "python ../manage.py runserver 0.0.0.0:80" | grep -v "grep"`
if ["$bool" == ""] 
then
echo "minusli@plushu" | sudo nohup python ../manage.py runserver 0.0.0.0:80 >> server.$today.log 2>&1 &else
date +%s > reload.py
fi
